<?php

namespace common\validate;

class AttributeValue extends BaseValidate
{
    // 验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.value', 'require')
            ->append('data.attribute_id', 'require')
            ->append('data.variable', 'max:8');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.variable', 'max:8');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // SaveBatch 验证场景定义
    public function sceneSaveBatch()
    {
        return $this->append('data', 'require|array');
    }

    // SaveBatch 验证场景定义
    public function sceneSaveBatchItem()
    {
        return $this->append('value', 'require')
            ->append('attribute_id', 'require')
            ->append('variable', 'max:8');
    }
}
